package cn.edu.sdjzu.knoverse.constant;

import cn.edu.sdjzu.knoverse.model.vo.result.ResultCodeEnum;
import cn.edu.sdjzu.knoverse.utils.exception.CustomException;
import lombok.Getter;

/**
 * 关系类型常量
 */
@Getter
public enum EdgeConstant {
    TEACH("教授", "TEACH", "教师-TEACH->课程"),
    CAN_ACCESS("访问权限", "CAN_ACCESS", "用户-CAN_ACCESS->课程"),
    // 前置课程
    PRE_COURSE("前置课程", "PRE_COURSE", "当前课程-PRE_COURSE->前置课程"),
    // 前置知识点
    PRE_KNOWLEDGE("前置知识点", "PRE_KNOWLEDGE", "当前知识点-PRE_KNOWLEDGE->前置知识点"),
    // 课程包含知识点
    COURSE_KNOWLEDGE("包含知识点", "COURSE_KNOWLEDGE", "课程-COURSE_KNOWLEDGE->知识点"),
    // 案例包含组件
    CASE_COMPONENT("包含组件", "CASE_COMPONENT", "案例-CASE_COMPONENT->组件"),
    // 组件包含文件附件
    COMPONENT_FILE("附件", "COMPONENT_FILE", "组件-COMPONENT_FILE->文件"),
    // 关联
    RELATED("关联", "RELATED", "组件-RELATED->知识点")
    ;


    private final String name;
    private final String type;
    private final String description;

    EdgeConstant(String name, String type, String description) {
        this.name = name;
        this.type = type;
        this.description = description;
    }

    /**
     * 获取enum
     */
    public static EdgeConstant getEdgeConstant(String type) {
        for (EdgeConstant edgeConstant : EdgeConstant.values()) {
            if (edgeConstant.getType().equals(type)) {
                return edgeConstant;
            }
        }
        // 不存在则抛出异常
        throw new CustomException(ResultCodeEnum.FAIL);
    }
}
